package com.myGroup.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.myGroup.mapper.TakePartMapper;
import com.myGroup.pojo.TakePart;
import com.myGroup.service.TakePartService;
import org.springframework.stereotype.Service;

@Service
public class TakePartServiceImpl extends ServiceImpl<TakePartMapper, TakePart> implements TakePartService {
    /**
     * 在takePartService中添加一个方法来检查是否存在
     * @param aId
     * @param uId
     * @return
     */
    public boolean existsByAIdAndUId(Integer aId, Integer uId) {
        // 以下是伪代码，你需要依据你的实际情况来编写查询逻辑
        QueryWrapper<TakePart> queryWrapper = new QueryWrapper<>();
        // a_id`和`u_id`字段联合起来应该是唯一的
        queryWrapper.eq("aId", aId);
        queryWrapper.eq("uId", uId);
        return this.count(queryWrapper) > 0;
    }
}
